package com.ioog.domain.model;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Table;


import org.hibernate.annotations.CollectionOfElements;


@Entity
@Table(name="location_detail")
public class LocationDetail implements Serializable {
	
	private static final long serialVersionUID = -14712386992251373L;

	@Id@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="location_detail_id")
	private Long id;
	
	@Column(name="email_address",length=50)
	private String emailAddress;
	
	@CollectionOfElements(fetch=FetchType.LAZY)
	@JoinTable(name="location_images",
			joinColumns=@JoinColumn(name="location_detail_id"))
	private Set<Image> images = new HashSet<Image>();
	
	public LocationDetail(){ }

	public Long getId() {
		return id;
	}

	public String getEmailAddress() {
		return emailAddress;
	}

	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	}

	public Set<Image> getImages() {
		return images;
	}

	public void setImages(Set<Image> images) {
		this.images = images;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((emailAddress == null) ? 0 : emailAddress.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		LocationDetail other = (LocationDetail) obj;
		if (emailAddress == null) {
			if (other.emailAddress != null)
				return false;
		} else if (!emailAddress.equals(other.emailAddress))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
	
	
}
